from rest_framework.throttling import AnonRateThrottle, UserRateThrottle, SimpleRateThrottle


class AnonBurstRateThrottle(AnonRateThrottle):
    scope = 'anon_burst'


class AnonSustainedRateThrottle(AnonRateThrottle):
    scope = 'anon_sustained'

class LoginBurstRateThrottle(AnonRateThrottle):
    scope = 'login_burst'

class LoginSustainedRateThrottle(AnonRateThrottle):
    scope = 'login_sustained'

class RegisterBurstRateThrottle(AnonRateThrottle):
    scope = 'register_burst'

class RegisterSustainedRateThrottle(AnonRateThrottle):
    scope = 'register_sustained'

class RefreshBurstRateThrottle(AnonRateThrottle):
    scope = 'refresh_burst'

class RefreshSustainedRateThrottle(AnonRateThrottle):
    scope = 'refresh_sustained'

 # non-anony user throttle   

class UserBurstRateThrottle(UserRateThrottle):
    scope = 'user_burst'

class UserSustainedRateThrottle(UserRateThrottle):
    scope = 'user_sustained'
    
    
class GlobalFrequencyThrottle(SimpleRateThrottle):
    scope = 'global_frequency'

    def get_cache_key(self, request, view):
        return f'{self.scope}_0'